import time

import selenium
from pycparser.c_ast import ID
from selenium import webdriver
# executable_path = r"D:\chromedriver\chromedriver.exe"
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.by import By
from logging import log
def test_01(mode):
    if mode == 0:
        print('远程docker容器启动')
        driver_chrome = selenium.webdriver.remote.webdriver.WebDriver(
            command_executor="http://192.168.73.132:5001/wd/hub",
            desired_capabilities=DesiredCapabilities.CHROME
        )
    elif mode == 1:
        print('本地启动谷歌浏览器')
        driver_chrome = webdriver.Chrome()
    driver_chrome.implicitly_wait(10)
    driver_chrome.get('http://www.baidu.com')
    element_keyword = driver_chrome.find_element(By.ID,'kw').send_keys('周杰伦')
    element_keyword_button = driver_chrome.find_element(By.ID,'su').click()
    time.sleep(2)
    ret=driver_chrome.find_element("id",'1')
    # ret = driver.find_element_by_id("1")
    print(ret.text)
    # if ret.text.startswith('周杰伦 - 百度百科'):
    if "黑色毛衣" in ret.text:
        print(""""测试通过""")
    else:
        print("""""""""""""""""测试失败""""""""""""""""")

if __name__ == '__main__':
    test_01(mode=1)